import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.geom.*;

public class Mover extends Rectangle2D.Double
{
	private Map level;
	private double x, y;
	private int x_Speed;

	private Random rand = new Random ();
	private ImageIcon mover = new ImageIcon ("images\\mover.png");
	
	Image img = mover.getImage ();
	
	public Mover (double x, double y)
	{
		super (x, y, 10, 10);
		
		x_Speed = rand.nextInt(3) + 5;
		
		this.x = super.x;
		this.y = super.y;
	}
	
	public void move ()
	{
		super.x += x_Speed;
	}
	
	public void detect ()
	{
		if (Map.line(level.getX(), level.getY(), level.getX(), level.getY() + level.getHeight()).intersects(this.getBounds())
			|| Map.line(level.getX() + level.getWidth(), level.getY(), level.getX() + level.getWidth(), level.getY() + level.getHeight()).intersects(this.getBounds()))
			x_Speed = -x_Speed;
	}
	
	public void reference (Map level)
	{
		this.level = level;
	}
	
	public int getXPos ()
	{
		return (int) super.x;
	}
	
	public int getYPos ()
	{
		return (int) super.y;
	}
}